// const path = require("path")
const dep = [
    "../src/Cesium/Cesium.js",
    "../src/Cesium/Widgets/widgets.css",
    "../src/mars3d/mars3d.css",
    "../src/mars3d/mars3d.js",
    // path.resolve(__dirname,"../","./Cesium/Cesium.js"),
    // path.resolve(__dirname,"../","./Cesium/Widgets/widgets.css"),
    // path.resolve(__dirname,"../","./mars3d/mars3d.css"),
    // path.resolve(__dirname,"../","./mars3d/mars3d.js"),
]

export function loadDep(){
    for(var i = 0;i<dep.length;i++){
        parseTypeBySuffix(dep[i]) ? createLink(dep[i]) : createScript(dep[i])
    }
}

function parseTypeBySuffix(path){
    let lastIndex = path.lastIndexOf(".")
    let type = path.substr(lastIndex + 1)
    return type === "css"
}

function createLink(path){
    let link = document.createElement("link")
    link.href = path
    document.head.appendChild(link)
}
function createScript(path){
    let script = document.createElement("script")
    script.src = path
    // script.defer = 'defer'
    document.head.appendChild(script)
}